#ifndef _EB0_AUDIO_MANAGER_H_
#define _EB0_AUDIO_MANAGER_H_

#include <EB0/Prereq.h>
#include <SFML/Audio.hpp>
#include <SFML/System.hpp>
#include <map>
#include <string>

namespace EB0
{
namespace Managers
{
	class AudioManager
	{
	public:
		~AudioManager();

		sf::Music* createMusic(char* filename); // const sf::Music*
		bool destroyMusic(sf::Music*& music);
		bool destroyMusic(char* filename);
		void destroyAllMusic();

		sf::SoundBuffer* createSoundBuffer(char* filename); // the data of a sound effect
		bool destroySoundBuffer(sf::SoundBuffer*& soundBuffer);
		bool destroySoundBuffer(char* filename);
		void destroyAllSoundBuffers();

		sf::Sound* createSound(char* refname, sf::SoundBuffer* soundBuffer);
		sf::Sound* createSound(char* refname, char* filename); // the manipulator for a sound buffer
		sf::Sound* fetchSound(char* refname);
		bool destroySound(sf::Sound*& sound);
		bool destroySound(char* refname);
		void destroyAllSounds();

		static AudioManager& getSingleton();
		static AudioManager* getSingletonPtr();

	private:
		typedef std::map<std::string, sf::Music*> MusicMap;
		typedef std::map<std::string, sf::SoundBuffer*> SoundBufferMap;
		typedef std::map<std::string, sf::Sound*> SoundMap;

		AudioManager();
		AudioManager(const AudioManager&) {}
		AudioManager &operator=(const AudioManager&);

		MusicMap mMusic;
		SoundBufferMap mSoundBuffers;
		SoundMap mSounds;

		mutable sf::Mutex mMutex;
		static AudioManager* mSingleton;
	};
} // namespace Managers
}

#endif // _EB0_AUDIO_MANAGER_H_